package com.zlp.controller;

import com.zlp.entity.User;
import com.zlp.exception.entity.Response;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @GetMapping("getUserList")
    public Response getUserList() {
        User user = new User();
        user.setAddress("1223456");
        user.setUserCode(123);
        user.setStatus(1);
        user.setUserName("zhang san");
        return new Response(user);
    }
    @GetMapping("getException")
    @Transactional(rollbackFor=Exception.class)
    public Response getException() {

        User user = new User();
        int e = 1/0 ;
        user.setAddress("1223456");
        user.setUserCode(123);
        user.setStatus(1);
        user.setUserName("zhang san");
        return new Response(user);
    }
}
